package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import DataObjects.Payment;

public class GetPaymentDetailsByOrderID {
	
	private  int orderID;
	private Vector<Payment> pay;
	
	public GetPaymentDetailsByOrderID( int orderID)
	{
		this.orderID=orderID;
	}
	
	public  Vector<Payment> getPaymentDetails ()
	{
		SQLConnection sc=new SQLConnection();
		try {
			PreparedStatement ps = sc.getConnection().prepareStatement("SELECT p.date,p.time,p.numtable,p.amount,p.changeOfPayment,p.typeOfPayment,p.orderID,p.tips From payment p where orderID=?");
			ps.setInt(1,orderID);
			ResultSet rs=ps.executeQuery();
			pay=new Vector<Payment>();
			 while(rs.next() )
		        {   
			Payment payment =new  Payment();
			payment.setDate(rs.getString(1));
			payment.setTime(rs.getString(2));
			payment.setNumtable(rs.getInt(3));
			payment.setAmount(rs.getFloat(4));
			payment.setChange(rs.getFloat(5));
			payment.setTypePayment(rs.getString(6));
			payment.setOrderid(rs.getInt(7));
			payment.setTips(rs.getFloat(8));
			
			
			pay.add(payment);
		        }
			ps.close();
			sc.getConnection().close();
		        
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		
		
		
		
		return pay;
	}
	

}
